// 实现简易 shallowReadonly
const shallowReadonly = (v) => {
  return new Proxy(v, {
    get(target, key) {
      // console.log('收集依赖')
      return target[key]
    },
    set(target, key, val) {
      console.log(`Set operation on key "${key}" failed: target is readonly.`)
      return true
    }
  })
}

let raw = {
  arr: [1, 2, 3]
}

let state = shallowReadonly(raw)

state.arr.push(4)

state.arr = [4, 5, 6]